package com.example.user.newsongpaly;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import java.util.List;

/**
 * Created by User on 2017/8/3.
 */

public class SongListAdpter extends BaseAdapter{
    Context context;
    List<String> list;

    public SongListAdpter(Context context, List<String> list) {
        this.context = context;
        this.list = list;
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int i) {
        return null;
    }

    @Override
    public long getItemId(int i) {
        return i;
    }
    Houder houder;
    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        if (view==null){
            houder = new Houder();
            view = View.inflate(context, R.layout.item,null);
            houder.textView = (TextView) view.findViewById(R.id.item);
            view.setTag(houder);
        }else {
            houder = (Houder) view.getTag();
        }
        houder.textView.setText(list.get(i));
        return view;
    }
    class Houder{
        TextView textView;
    }
}
